package com.tjsinfo.tjsoa.messageImportant.dao;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.tjsinfo.tjsoa.messageImportant.vo.MessageImportantIncept;

/**
 * A data access object (DAO) providing persistence and search support for
 * MessageImportantIncept entities. Transaction control of the save(), update()
 * and delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.tjsinfo.tjsoa.messageImportant.vo.MessageImportantIncept
 * @author MyEclipse Persistence Tools
 */

public class MessageImportantInceptDAO extends HibernateDaoSupport implements IMessageImportantInceptDAO {
	private static final Log log = LogFactory
			.getLog(MessageImportantInceptDAO.class);

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.IMessageImportantInceptDAO#save(com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.MessageImportantIncept)
	 */
	public String save(MessageImportantIncept transientInstance) {
		log.debug("saving MessageImportantIncept instance");
		String id="";
		try {
			getHibernateTemplate().save(transientInstance);
			
			 id= transientInstance.getId();
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
		return id;
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.IMessageImportantInceptDAO#delete(com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.MessageImportantIncept)
	 */
	public void delete(MessageImportantIncept persistentInstance) {
		log.debug("deleting MessageImportantIncept instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.IMessageImportantInceptDAO#findById(java.lang.Integer)
	 */
	public MessageImportantIncept findById(java.lang.Integer id) {
		log.debug("getting MessageImportantIncept instance with id: " + id);
		try {
			MessageImportantIncept instance = (MessageImportantIncept) getHibernateTemplate()
					.get(
							"com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.MessageImportantIncept",
							id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.IMessageImportantInceptDAO#findByExample(com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.MessageImportantIncept)
	 */
	public List findByExample(MessageImportantIncept instance) {
		log.debug("finding MessageImportantIncept instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance); 
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.IMessageImportantInceptDAO#findByProperty(java.lang.String, java.lang.Object)
	 */
	public List findByProperty(String propertyName, Object value) {
		log.debug("finding MessageImportantIncept instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from MessageImportantIncept as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.IMessageImportantInceptDAO#findAll()
	 */
	public List findAll() {
		log.debug("finding all MessageImportantIncept instances");
		try {
			String queryString = "from MessageImportantIncept";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.IMessageImportantInceptDAO#merge(com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.MessageImportantIncept)
	 */
	public MessageImportantIncept merge(MessageImportantIncept detachedInstance) {
		log.debug("merging MessageImportantIncept instance");
		try {
			MessageImportantIncept result = (MessageImportantIncept) getHibernateTemplate()
					.merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.IMessageImportantInceptDAO#attachDirty(com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.MessageImportantIncept)
	 */
	public void attachDirty(MessageImportantIncept instance) {
		log.debug("attaching dirty MessageImportantIncept instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.IMessageImportantInceptDAO#attachClean(com.tjsinfo.tjsoa.MessageImportant.MessageImportant_Incept.MessageImportantIncept)
	 */
	public void attachClean(MessageImportantIncept instance) {
		log.debug("attaching clean MessageImportantIncept instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}
}